<template>
  <div>
    <Top/>
    <!-- 搜索框 -->
    <div class="banner">
      <form action="">
        <input type="text" placeholder="请搜索喜欢的游戏" />
      </form>
      <span>搜索游戏</span>
    </div>
    <div class="module">
      <!-- 字母 -->
      <!-- class="search_fristword blue-hotgames_box" -->
      <div 
        class="search_fristword"
        :class="{'blue-hotgames_box':check==index}" 
        v-for="(item,index) in list" 
        :key="index"
        @click="changenum(index,item)"
      >
        {{ item.name }}
      </div>
    </div>
    <!-- 内容区 -->
    <div class="games-content">
      <!-- 每一个小盒子 -->
      <router-link to="release"
        class="hotgames_box" 
        v-for="(item, index) in hotgames" 
        :key="index"
        
      >
        <img :src="'https://img2.taoshouyou.com' + item.pic" />
        <div class="gamenamediv">{{ item.name }}</div>
      </router-link>

    </div>

    
  </div>
</template>

<script>
import request from "../uitls/request.js";
import Top from '../components/top'

export default {
  components: {
    Top
  },
  data() {
    return {
      list: [{ name: "热", key: "hot" }],
      hotgames: [],
      check:0,
    };
  },
  methods: {
    changenum(i,item) {
      this.check=i;
      request({
      headers: {
        "x-requested-with": "XMLHttpRequest",
      },
      url: `/tsy/games/list/index?letter=${item.key}&gamename=&goodsid=0&parentid=0&type=0&isresell=0`,
    }).then((val) => {
      var a = val.data;
      a.splice(15,1)
      this.hotgames = a;
    });
    }
  },
  created() {
    for (var i = 0; i < 26; i++) {
      this.list.push({
        name: String.fromCharCode(65 + i),
        key: String.fromCharCode(65 + i),
      });
    }
    request({
      headers: {
        "x-requested-with": "XMLHttpRequest",
      },
      url: `/tsy/games/list/index?letter=hot&gamename=&goodsid=0&parentid=0&type=0&isresell=0`,
    }).then((val) => {
      var a = val.data;
      a.splice(15,1)
      this.hotgames = a;
    });
  },
};
</script>

<style lang="less" scoped>
@import url("../assets/css/sell.css");
.games-content {
  width: 100%;
  margin-bottom: 60px;
  border-bottom: 1px solid #ccc;
}
.hotgames_box {
  display: inline-block;
  width: 20%;
  height: 50px;
  margin-left: 15px;
  margin-top: 20px;
  
}
.hotgames_box img {
  width: 90%;
  height: 120%;
  border-radius: 5px;
}
.search_fristword{
  width: 50px;
  line-height: 45px;
  margin: 1px 6px;
  text-align: center;
  font-size: .15rem;
  background: #FFF;
  color: #333;
  background-color: #f5f5f5;
  border-right: .01rem solid #F2F3F6;
}
.blue-hotgames_box{
  background: yellow;
}
.gamenamediv{
  font-size: 12px;
  text-align: center;
}
</style>